<?php

require_once dirname(__FILE__).'/../lib/journalGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/journalGeneratorHelper.class.php';

/**
 * journal actions.
 *
 * @package    theconnexter
 * @subpackage journal
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class journalActions extends autoJournalActions
{
	public function executeBatchActive(sfWebRequest $request){
		$this->updateTable($request,1);
	}
	public function executeBatchDesactive(sfWebRequest $request){
		$this->updateTable($request,0);
	}
	public function updateTable(sfWebRequest $request,$etat){
		$ids = $request->getParameter('ids');
		foreach($ids as $id){
			Doctrine_core::getTable('journal')->activeDeactiveJournal($id, $etat);
		}
	}
        //permet de lister les articles à ordonner
        public function executeListOrderArticle(sfWebRequest $request){
            $this->listaricles=Doctrine_core::getTable('journal')->getArticlesJ($request->getParameter('id'));
        }
        //met à jour la position des articles
        public function executeUpdateOrderarticle(sfWebRequest $request){
            $nbre=intval($request->getParameter('nbrearticles'));
           // print_r($request);
            $idj=intval($request->getParameter('idjournal'));
            for ($jj=0; $jj<$nbre; $jj++){
                $idart=intval($request->getParameter('order1'.$jj));
                $order=intval($request->getParameter('order'.$jj));
                Doctrine_core::getTable('journalarticle')->updateOrder($idj, $idart, $order);
            }
            
            $this->redirect('@journal');
        }
}
